﻿#ifndef CANTHREAD_H
#define CANTHREAD_H

#include <QThread>
#include "ControlCAN.h"
#include <QDebug>
#include <QMutex>

class CANThread : public QThread
{
    Q_OBJECT
public:
    CANThread();

    void stop();

    bool openCAN(const int &deviceType,const int &debicIndex,const int &baundRate,const int &debicCom);

    void closeCAN();

public slots:
    void sendData(int ID,const QByteArray &data);

private:
    QByteArray BytetoQByteArray(const BYTE* data, int size);

    void BytefromQByteArray(const QByteArray &src, BYTE* dest);

private:
    int m_deviceType;
    int m_debicIndex;
    int m_baundRate;
    int m_debicCom;

    bool stopped;

    QMutex m_mutex;

//signals:
//    void getProtocolData(int ID,const QByteArray &frame);

private:
    void run();
    void sleep(unsigned int msec);

};

#endif // CANTHREAD_H
